<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>screen+history</title>
    <style>
        body{
            margin: 200px;
            background: #000000;
            color: #ffffff;
        }
    </style>
</head>
<body>
    <span id="sp">5</span>秒后跳转到http://baidu.com
    <br>
    <button onclick="fn()">点击跳转</button>

<script type="text/javascript">
    // console.log(window.screen);
    // console.log(window.history);
    // history.back()//回到上一个页面
    // history.forward()//回到下一个页面
    // history.go(number)//number为正为负，表示向上向下跳转几个页面

    // location是操作地址栏的
    // console.log(location);
    // location.href = "值"用于跳转页面，设置跳转页面的值

    function fn() {
        location.href = "http://baidu.com";
    }

    var n = 5;
    sp.innerHTML = n;
    setInterval(function () {
        n--;
        if(n==0){
            location.href = "http://baidu.com";
        }else {
            sp.innerHTML = n;
        }
    },1000);

</script>

</body>
</html>